#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QPainter>
#include <QPushButton>
#include <QTextEdit>
#include <QSplitter>
#include <QTextBrowser>
#include <QHBoxLayout>
#include <QDebug>
#include <QFileDialog>
#include <QTextStream>
#include <QTextCodec>
#include <QThreadPool>
#include <QMessageBox>
#include <QSet>
#include <QMap>
#include <QVector>
#include <QTimer>
#include <QTextCursor>
#include <QTextCharFormat>
#include <QMutex>
#include <QMutexLocker>
#include <QInputDialog>
#include "cutjob.h"
#include "procdialog.h"
#include "statjob.h"
#include "aboutdialog.h"
namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
private:
    QVector<QString> getdic();
    QSet<QChar> getcut();
    QVector<QString> getstop();
    QSet<QString> getblock();
    Ui::MainWindow *ui;
    void init();
    QTextCodec * findcode();
    void addwork(QString &);
    const static int MAXSHOWSZ =100000;
    const static int PERWORK = 1000;
    const static int SLEEPTIME = 300;//ms
    const static int DURTIME = 200;//ms
    QTimer * tim;
    QSplitter * spli;
    QTextEdit * txtedit;
    QTextBrowser * wdbrowser;

    QTextCharFormat redfmt;
    QTextCharFormat normalfmt;
    QString testfn;
    ProcDialog * progdlg;
    QThreadPool * poll;
    QMap<int ,Statjob> jobset;
    int totwd;
    int finishwd;
    int totthread;
    int finishth;
    int currid;
    bool cmdfile;
    QMutex mut;
private slots:
    void on_actauthor_triggered();
    void on_actadddic_triggered();
    void on_actaddcut_triggered();
    void on_actaddblock_triggered();
    void opentxt();
    void startcut();
    void cmdclear();
    void updatedlg(int id ,int val);
    void quitjob();
    void okwork(int id , QStringList cutwd);
    void showcutwd();
protected:
void paintEvent ( QPaintEvent * event );
};

#endif // MAINWINDOW_H
